#include "rclcpp/rclcpp.hpp"
#include "geometry_msgs/msg/twist.hpp"

class vel_pub : public rclcpp::Node {
public:
    vel_pub() : Node("velocity_publisher") {
        publisher_ = this->create_publisher<geometry_msgs::msg::Twist>("cmd_vel", 10);
        timer_ = this->create_wall_timer(
            std::chrono::milliseconds(500),
            std::bind(&vel_pub::publish_velocity, this)
        );
    }

private:
    void publish_velocity() {
        auto message = geometry_msgs::msg::Twist();
        message.linear.x = 0.1;  // Set linear velocity
        message.angular.z = 0.0; // Set angular velocity
        publisher_->publish(message);
        RCLCPP_INFO(this->get_logger(), "Publishing: linear.x: '%f', angular.z: '%f'", message.linear.x, message.angular.z);
    }

    rclcpp::Publisher<geometry_msgs::msg::Twist>::SharedPtr publisher_;
    rclcpp::TimerBase::SharedPtr timer_;
};

int main(int argc, char * argv[]) {
    rclcpp::init(argc, argv);
    rclcpp::spin(std::make_shared<vel_pub>());
    rclcpp::shutdown();
    return 0;
}
